Skip to content

Add link and unsubscribe metadata to CLI reads - #310

Merged
huacnlee merged 1 commit into
huacnlee:mainfrom
klaudworks:feat/cli-read-links
Sep 30, 2026
Merged

huacnlee merged 1 commit into
huacnlee:mainfrom
klaudworks:feat/cli-read-links

Conversation

@klaudworks

Copy link
Copy Markdown
Collaborator

Summary

Expose email link destinations and newsletter unsubscribe metadata through the existing omamail read / mail.read result. This addresses the remaining newsletter-workflow gap discussed in #154: the CLI already lists, reads, sends and trashes mail, but previously discarded HTML anchor destinations and unsubscribe headers.

  • message.links: {text, url} entries from anchors in the sanitized document, including links missing from a message's plain-text alternative.
  • message.unsubscribe: deduplicated urls from List-Unsubscribe, plus the sender's oneClick declaration when an HTTPS destination is available.
  • Empty arrays and oneClick: false when this metadata is absent. Plain-text URLs stay in the body text. Provider metadata availability still applies.

This is an additive, provider-neutral read projection. No new command or flag is needed, no QML dependency is introduced, and the plugin's backend pin/API requirements do not change. Cross-account search is tracked separately in #308.

Boundaries

Link extraction reuses the existing bounded sanitized-document traversal and validates the exported destination after HTML-entity decoding. HTTP(S) destinations use the existing public-host spelling policy; mailto destinations are returned as data. Raw HTML, image/resource URLs, unrelated headers and document attributes remain excluded. Reading still leaves read state unchanged and does not visit links or perform unsubscribe actions.

oneClick reports the sender's declaration, not verified DKIM coverage or permission to POST. The caller remains responsible for any subsequent network request, including DNS/address validation. Header URL bytes are not HTML-decoded.

Verification

  • All make validate stages passed across the initial run and the resumed remaining-stage run after a local harness restart: 570 Rust unit tests, 33 CLI tests, remaining Rust integrations, JavaScript/shell checks, 1,075 main QML tests, 6 Outlook and 64 sidebar checks, the native Qt resource-isolation test, standalone composition, QML lint and plugin validation.
  • Final focused verification after link-decoding/bounding refinements: all 13 read/projection tests and the real CLI IMAP/MIME fixture passed. The fixture verifies HTML-only anchors, entity decoding, folded unsubscribe headers, unchanged plain text, BODY.PEEK and exclusion of tracking-image URLs and unsafe schemes.
  • Provider-neutral recording fixtures exercise all five provider identities and verify no extra operation beyond the read; this is not live-vendor interoperability evidence.
  • Changed-file formatting and whitespace checks passed. Strict Clippy exposed five pre-existing collapsible_if / needless_return diagnostics in untouched calendar, credentials, IMAP and mail-test code; all-target Clippy passed with only those two lint classes allowed.

Security

PASS — scoped to the new read projection. Sender-controlled anchor attributes are decoded once before destination validation; header targets retain their original non-HTML interpretation. Tests cover unsafe schemes, private/loopback and numeric-host spellings, ambiguous HTTP syntax, credentials, CR/LF/NUL, backslashes, Unicode, encoded quotes, HTML entities, missing metadata and nested-anchor label amplification. The projection contains no DNS, network, browser, process-launch or mail-mutation operation. Existing raw-content/resource exclusions and document bounds remain in force. This is not an audit of arbitrary downstream clients or live-provider behavior.

Release Notes

  • Show HTML link destinations and newsletter unsubscribe metadata in CLI mail reads, enabling automation to find unsubscribe targets without exporting raw HTML.

@huacnlee
huacnlee merged commit ce2bac9 into huacnlee:main Sep 30, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants